local congLi = fk.CreateSkill {
  name = "steam__congli",
}

Fk:loadTranslationTable{
  ["steam__congli"] = "从利",
  [":steam__congli"] = "其他角色准备阶段， 你与其同时可选择其一张牌，你获得其选择的牌，本回合“诛权”失效；弃置你选择的牌，其视为对你使用【决斗】。",

  ["#steam__congli-choose"] = "从利：选择一名角色，你与其同时选择一张牌",
  ["#steam__congli-choice"] = "从利：选择一张牌， %src 将获得你选择的牌，你弃置你选择的牌并视为对其使用【决斗】",
  ["#steam__congli-discard"] = "从利：弃置 %dest 选择的一张牌，视为对其使用【决斗】",

  ["$steam__congli1"] = "天下攘攘，皆为利往。",
  ["$steam__congli2"] = "犬从主，人从利！",
}
local U = require "packages/utility/utility"

congLi:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(congLi.name) and target.phase == Player.Start and target ~= player
  end,
  on_cost=Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = target

    local card = room:askToChooseCards(player, {
      target = to,
      flag = "he",
      skill_name = congLi.name,
      min = 0,
      max = 1,
    })
    local card2 = room:askToChooseCards(to, {
      target = to,
      flag = "he",
      skill_name = congLi.name,
      min = 0,
      max = 1,
    })
    if #card2~=0 then 
      room:obtainCard(player, card2, true, fk.ReasonPrey)--获得对方选择的牌
      room:invalidateSkill(player, "steam__zhuquan", "-turn")
    end
    if #card~=0 then 
      if #card2==0 then
        room:throwCard(card, congLi.name, to, player)
      end
 
      if #card2~=0 and card[1]~=card2[1] then
        room:throwCard(card, congLi.name, to, player)
      elseif #card2~=0 and card[1]==card2[1] then
        room:throwCard(card, congLi.name, player, player)

      end
    
      if player.dead or to.dead or to:isProhibited(player, Fk:cloneCard("duel"))  then return end
      room:useVirtualCard("duel", nil, to, {player}, congLi.name)
      
    end
  end,
})

return congLi
